<?php
//Inclusion du header de la page
include 'header.php';
?>

<script type="text/javascript">
    
    $(document).ready(function(){
        
        $("#msgErr").hide();
        
        $("#formConnexion").submit(function(e) {
            
            e.preventDefault();
            data=$("#formConnexion").serialize();
            
            $.ajax({
                type: 'POST',
                url: 'connexion.php',
                data: data,
                success: function(data, textStatus, jqXHR) {
                    if(data==1){
                        url = "creationSite.php";
                        $(location).attr('href',url);
                    }else if(data == 0){
                        $("#msgErr").show();
                    }
                },
                error: function(jqXHR, textStatus, errorThrown) {
                }
            });
            
        })
    });
    
</script>
</head>
<body>
    <section id="main">
                <article id="connexionA" class="module width_quarter">
                    <header><h3>Connexion</h3></header>
                    <form id="formConnexion" class="form" action="#" method="POST">
                        <div class="module_content">
                            <fieldset>
                                <label for="username">Nom d'utilisateur</label>
                                <input type="text" name="username" id="username" required="required">
                            </fieldset>
                            <fieldset>
                                <label for="password">Mot de passe</label>
                                <input type="password" name="password" id="password" required="required">
                            </fieldset>
                        </div>
                        <footer>
                            <div class="submit_link">
                                <input type="submit" value="Connexion" class="alt_btn">
                            </div>
                        </footer>
                    </form>
                </article>

        <article id="msgErr" class="module width_half">
            <h4 class="alert_error">Nom d'utilisateur ou mot de passe incorrect</h4>
        </article>

    </section>
</body>
</html>